import { createStore } from 'vuex'
import persist from 'vuex-persistedstate'
export default createStore({
  state: {
    historyList:[], // 历史记录
  },
  mutations: {
    add(state,val){
      let i = state.historyList.findIndex(item => item == val);
      if (i>-1){
        state.historyList.splice(i,1);
      }
      state.historyList.unshift(val);
    },
    delectAll(state){
      state.historyList = [];
    },
    delect(state,i){
      state.historyList.splice(i,1);
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [
    new persist({
      storage: window.localStorage,
    }),
  ],
})
